#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, c[91], t[91], w[91], m, tot, a[3002], b[3002], sum, ans = 0, dp[10004];

void dfs(int i, int rem, int rw) {
	if (rem < 0) return;
	if (i == n + 1) {
		ans = max(ans, rw);
		return;
	}
	for (int j = 0; j <= c[i]; ++j) {
		dfs(i + 1, rem - j * t[i], rw + j * w[i]);
	}
}

signed main() {
	freopen("book.in", "r", stdin);
	freopen("book.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> c[i];
		sum += c[i];
	}
	for (int i = 1; i <= n; ++i) cin >> t[i];
	for (int i = 1; i <= n; ++i) cin >> w[i];
	cin >> m;
	if (m <= 10000) {
		for (int i = 1; i <= n; ++i) {
			int sum = 0;
			for (int j = 1; ; j *= 2) {
				if (sum + j <= c[i]) {
					a[++tot] = j * t[i];
					b[tot] = j * w[i];
					sum += j;
				} else {
					if (c[i] - sum > 0) {
						a[++tot] = (c[i] - sum) * t[i];
						b[tot] = (c[i] - sum) * w[i];
					}
					break;
				}
			}
		}
		for (int i = 1; i <= tot; ++i) {
			for (int j = m; j >= a[i]; --j) {
				dp[j] = max(dp[j], dp[j - a[i]] + b[i]);
			}
		}
		cout << dp[m] << "\n";
	} else {
		dfs(1, m, 0);
		cout << ans << "\n";
		return 0;
	}
	return 0;
}
